package com.explorati.design_pattern.comparson.structural.proxy;

import java.util.Random;

public class Proxy implements IStar {

	private IStar star;

	public Proxy(IStar star) {
		this.star = star;
	}

	@Override
	public void action() {
		Random rand = new Random();
		if (rand.nextBoolean()) {
			System.out.println("经纪人同意安排明星演戏");
			this.star.action();
		} else {
			System.out.println("明星档期已满，不能安排演戏");
		}
	}

	@Override
	public void advert() {
		Random rand = new Random();
		if (rand.nextBoolean()) {
			System.out.println("经纪人同意安排明星广告代言");
			this.star.action();
		} else {
			System.out.println("明星档期已满，不能安排广告代言");
		}
	}

}
